package com.appwoo.txtws.activity;

import android.app.ProgressDialog;
import android.content.ContentResolver;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.res.Resources;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.RectF;
import android.media.ExifInterface;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.Toast;
import com.appwoo.txtws.adapter.WallpaperListAdapter;
import com.appwoo.txtws.adapter.WallpaperListAdapter.DownloadImageTask;
import com.appwoo.txtws.adapter.WallpaperListAdapter.DownloadImageTaskAfter;
import com.appwoo.txtws.bean.WallpaperBean;
import com.appwoo.txtws.component.DBHelper;
import com.appwoo.txtws.component.Global;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.concurrent.CountDownLatch;

public class CropActivity extends MonitoredActivity
{
  public static final String CROP_IMAGE_URI = "crop_image_uri";
  private static final int DEFAULT_HEIGHT = 384;
  private static final int DEFAULT_WIDTH = 512;
  public static final String IMAGE_URI = "iamge_uri";
  private static final int ONE_K = 1024;
  private static final int ONE_M = 1048576;
  private static final boolean RECYCLE_INPUT = true;
  private static final int WALLPAPER_SET_SUCCESS = 1;
  String cropPath01 = null;
  private int height;
  HighlightView hv;
  private boolean isDownload = false;
  private int mAspectX;
  private int mAspectY;
  private Bitmap mBitmap;
  private Button mBtnSave;
  private boolean mCircleCrop = false;
  private ContentResolver mContentResolver;
  HighlightView mCrop;
  private DBHelper mDBHelper;
  private final Handler mHandler = new Handler();
  private Handler mHandler2;
  private CropImageView mImageView;
  private int mOutputX;
  private int mOutputY;
  Runnable mRunFaceDetection = new Runnable()
  {
    Matrix mImageMatrix;
    float mScale = 1.0F;

    private void makeDefault()
    {
      if (CropActivity.this.hv != null)
        CropActivity.this.mImageView.remove(CropActivity.this.hv);
      CropActivity.this.hv = new HighlightView(CropActivity.this.mImageView);
      int i = CropActivity.this.mBitmap.getWidth();
      int j = CropActivity.this.mBitmap.getHeight();
      Rect localRect = new Rect(0, 0, i, j);
      DisplayMetrics localDisplayMetrics = new DisplayMetrics();
      CropActivity.this.getWindowManager().getDefaultDisplay().getMetrics(localDisplayMetrics);
      int k = localDisplayMetrics.widthPixels;
      int m = localDisplayMetrics.heightPixels;
      int n = 4 * Math.min(i, j) / 5;
      int i1 = n * k / m;
      RectF localRectF;
      HighlightView localHighlightView;
      Matrix localMatrix;
      boolean bool1;
      if ((CropActivity.this.mAspectX != 0) && (CropActivity.this.mAspectY != 0))
      {
        if (CropActivity.this.mAspectX > CropActivity.this.mAspectY)
          n = i1 * CropActivity.this.mAspectY / CropActivity.this.mAspectX;
      }
      else
      {
        int i2 = (i - i1) / 2;
        int i3 = (j - n) / 2;
        localRectF = new RectF(i2, i3, i2 + i1, i3 + n);
        localHighlightView = CropActivity.this.hv;
        localMatrix = this.mImageMatrix;
        bool1 = CropActivity.this.mCircleCrop;
        if ((CropActivity.this.mAspectX == 0) || (CropActivity.this.mAspectY == 0))
          break label345;
      }
      label345: for (boolean bool2 = true; ; bool2 = false)
      {
        localHighlightView.setup(localMatrix, localRect, localRectF, bool1, bool2);
        CropActivity.this.mImageView.add(CropActivity.this.hv);
        return;
        i1 = n * CropActivity.this.mAspectX / CropActivity.this.mAspectY;
        break;
      }
    }

    public void run()
    {
      this.mImageMatrix = CropActivity.this.mImageView.getImageMatrix();
      this.mScale = (1.0F / this.mScale);
      CropActivity.this.mHandler.post(new Runnable()
      {
        public void run()
        {
          CropActivity.1.this.makeDefault();
          CropActivity.this.mImageView.invalidate();
          if (CropActivity.this.mImageView.mHighlightViews.size() == 1)
          {
            CropActivity.this.mCrop = ((HighlightView)CropActivity.this.mImageView.mHighlightViews.get(0));
            CropActivity.this.mCrop.setFocus(true);
          }
        }
      });
    }
  };
  boolean mSaving;
  private boolean mScale;
  private boolean mScaleUp = true;
  private int rotation = 0;
  private int sampleSize = 1;
  int sdCard = -1;
  Uri targetUri;
  private boolean tipLoadFail = true;
  private String wallpaperType;
  private String wallpaperValue;
  private WallpaperBean wb;
  private int width;

  private void download()
  {
    if (!isNetworkAvailable(this))
    {
      alertMessage(getString(2131428051));
      this.tipLoadFail = false;
      return;
    }
    this.isDownload = true;
    showProgress("");
    WallpaperListAdapter localWallpaperListAdapter = new WallpaperListAdapter();
    WallpaperListAdapter.DownloadImageTaskAfter local5 = new WallpaperListAdapter.DownloadImageTaskAfter()
    {
      public void doOther(String paramAnonymousString)
      {
        if ("FAIL".equals(paramAnonymousString))
        {
          CropActivity.this.closeProgress();
          CropActivity.this.finish();
        }
        do
        {
          return;
          if ("STORAGE_SIZE".equals(paramAnonymousString))
          {
            CropActivity.this.closeProgress();
            CropActivity.this.finish();
            return;
          }
        }
        while (!"SUCCESS".equals(paramAnonymousString));
        CropActivity.this.wallpaperValue = CropActivity.this.wb.getLocalLarge();
        CropActivity.this.mBitmap = BitmapFactory.decodeFile(CropActivity.this.wallpaperValue);
        CropActivity.this.startFaceDetection(false);
        CropActivity.this.isDownload = false;
        CropActivity.this.closeProgress();
      }
    };
    localWallpaperListAdapter.getClass();
    new WallpaperListAdapter.DownloadImageTask(localWallpaperListAdapter, null, this.wb, this, "aa", local5).execute(new String[] { "" });
  }

  // ERROR //
  private void getBitmap()
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_1
    //   2: ldc 197
    //   4: aload_0
    //   5: getfield 199	com/appwoo/txtws/activity/CropActivity:wallpaperType	Ljava/lang/String;
    //   8: invokevirtual 203	java/lang/String:equals	(Ljava/lang/Object;)Z
    //   11: istore 4
    //   13: iload 4
    //   15: ifeq +50 -> 65
    //   18: aload_0
    //   19: aload_0
    //   20: getfield 205	com/appwoo/txtws/activity/CropActivity:targetUri	Landroid/net/Uri;
    //   23: invokespecial 209	com/appwoo/txtws/activity/CropActivity:getInputStream	(Landroid/net/Uri;)Ljava/io/InputStream;
    //   26: astore_1
    //   27: aload_0
    //   28: aload_1
    //   29: invokestatic 215	android/graphics/BitmapFactory:decodeStream	(Ljava/io/InputStream;)Landroid/graphics/Bitmap;
    //   32: putfield 104	com/appwoo/txtws/activity/CropActivity:mBitmap	Landroid/graphics/Bitmap;
    //   35: aload_1
    //   36: ifnull +7 -> 43
    //   39: aload_1
    //   40: invokevirtual 220	java/io/InputStream:close	()V
    //   43: return
    //   44: astore 11
    //   46: aload 11
    //   48: invokevirtual 223	java/io/IOException:printStackTrace	()V
    //   51: goto -16 -> 35
    //   54: astore_2
    //   55: aload_1
    //   56: ifnull +7 -> 63
    //   59: aload_1
    //   60: invokevirtual 220	java/io/InputStream:close	()V
    //   63: aload_2
    //   64: athrow
    //   65: ldc 225
    //   67: aload_0
    //   68: getfield 199	com/appwoo/txtws/activity/CropActivity:wallpaperType	Ljava/lang/String;
    //   71: invokevirtual 203	java/lang/String:equals	(Ljava/lang/Object;)Z
    //   74: istore 5
    //   76: aconst_null
    //   77: astore_1
    //   78: iload 5
    //   80: ifeq -45 -> 35
    //   83: aload_0
    //   84: getfield 146	com/appwoo/txtws/activity/CropActivity:wb	Lcom/appwoo/txtws/bean/WallpaperBean;
    //   87: astore 6
    //   89: aconst_null
    //   90: astore_1
    //   91: aload 6
    //   93: ifnull -58 -> 35
    //   96: ldc 227
    //   98: aload_0
    //   99: getfield 146	com/appwoo/txtws/activity/CropActivity:wb	Lcom/appwoo/txtws/bean/WallpaperBean;
    //   102: invokevirtual 233	com/appwoo/txtws/bean/WallpaperBean:getType	()Ljava/lang/String;
    //   105: invokevirtual 203	java/lang/String:equals	(Ljava/lang/Object;)Z
    //   108: istore 7
    //   110: aconst_null
    //   111: astore_1
    //   112: iload 7
    //   114: ifeq +102 -> 216
    //   117: aload_0
    //   118: getfield 146	com/appwoo/txtws/activity/CropActivity:wb	Lcom/appwoo/txtws/bean/WallpaperBean;
    //   121: invokevirtual 236	com/appwoo/txtws/bean/WallpaperBean:getLocalLarge	()Ljava/lang/String;
    //   124: ifnull +18 -> 142
    //   127: ldc 164
    //   129: aload_0
    //   130: getfield 146	com/appwoo/txtws/activity/CropActivity:wb	Lcom/appwoo/txtws/bean/WallpaperBean;
    //   133: invokevirtual 236	com/appwoo/txtws/bean/WallpaperBean:getLocalLarge	()Ljava/lang/String;
    //   136: invokevirtual 203	java/lang/String:equals	(Ljava/lang/Object;)Z
    //   139: ifeq +12 -> 151
    //   142: aload_0
    //   143: invokespecial 238	com/appwoo/txtws/activity/CropActivity:download	()V
    //   146: aconst_null
    //   147: astore_1
    //   148: goto -113 -> 35
    //   151: new 240	java/io/File
    //   154: dup
    //   155: aload_0
    //   156: getfield 146	com/appwoo/txtws/activity/CropActivity:wb	Lcom/appwoo/txtws/bean/WallpaperBean;
    //   159: invokevirtual 236	com/appwoo/txtws/bean/WallpaperBean:getLocalLarge	()Ljava/lang/String;
    //   162: invokespecial 242	java/io/File:<init>	(Ljava/lang/String;)V
    //   165: astore 9
    //   167: aconst_null
    //   168: astore_1
    //   169: aload 9
    //   171: ifnull +36 -> 207
    //   174: aload 9
    //   176: invokevirtual 246	java/io/File:exists	()Z
    //   179: istore 10
    //   181: aconst_null
    //   182: astore_1
    //   183: iload 10
    //   185: ifeq +22 -> 207
    //   188: aload_0
    //   189: aload_0
    //   190: getfield 146	com/appwoo/txtws/activity/CropActivity:wb	Lcom/appwoo/txtws/bean/WallpaperBean;
    //   193: invokevirtual 236	com/appwoo/txtws/bean/WallpaperBean:getLocalLarge	()Ljava/lang/String;
    //   196: invokestatic 250	android/graphics/BitmapFactory:decodeFile	(Ljava/lang/String;)Landroid/graphics/Bitmap;
    //   199: putfield 104	com/appwoo/txtws/activity/CropActivity:mBitmap	Landroid/graphics/Bitmap;
    //   202: aconst_null
    //   203: astore_1
    //   204: goto -169 -> 35
    //   207: aload_0
    //   208: invokespecial 238	com/appwoo/txtws/activity/CropActivity:download	()V
    //   211: aconst_null
    //   212: astore_1
    //   213: goto -178 -> 35
    //   216: aload_0
    //   217: aload_0
    //   218: invokevirtual 254	com/appwoo/txtws/activity/CropActivity:getResources	()Landroid/content/res/Resources;
    //   221: aload_0
    //   222: invokevirtual 254	com/appwoo/txtws/activity/CropActivity:getResources	()Landroid/content/res/Resources;
    //   225: aload_0
    //   226: getfield 146	com/appwoo/txtws/activity/CropActivity:wb	Lcom/appwoo/txtws/bean/WallpaperBean;
    //   229: invokevirtual 257	com/appwoo/txtws/bean/WallpaperBean:getName	()Ljava/lang/String;
    //   232: ldc_w 259
    //   235: aload_0
    //   236: invokevirtual 262	com/appwoo/txtws/activity/CropActivity:getPackageName	()Ljava/lang/String;
    //   239: invokevirtual 268	android/content/res/Resources:getIdentifier	(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I
    //   242: invokestatic 272	android/graphics/BitmapFactory:decodeResource	(Landroid/content/res/Resources;I)Landroid/graphics/Bitmap;
    //   245: putfield 104	com/appwoo/txtws/activity/CropActivity:mBitmap	Landroid/graphics/Bitmap;
    //   248: aconst_null
    //   249: astore_1
    //   250: goto -215 -> 35
    //   253: astore_3
    //   254: goto -191 -> 63
    //   257: astore 8
    //   259: return
    //
    // Exception table:
    //   from	to	target	type
    //   18	35	44	java/io/IOException
    //   2	13	54	finally
    //   18	35	54	finally
    //   46	51	54	finally
    //   65	76	54	finally
    //   83	89	54	finally
    //   96	110	54	finally
    //   117	142	54	finally
    //   142	146	54	finally
    //   151	167	54	finally
    //   174	181	54	finally
    //   188	202	54	finally
    //   207	211	54	finally
    //   216	248	54	finally
    //   59	63	253	java/io/IOException
    //   39	43	257	java/io/IOException
  }

  // ERROR //
  private void getBitmapSize()
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_1
    //   2: aload_0
    //   3: aload_0
    //   4: getfield 205	com/appwoo/txtws/activity/CropActivity:targetUri	Landroid/net/Uri;
    //   7: invokespecial 209	com/appwoo/txtws/activity/CropActivity:getInputStream	(Landroid/net/Uri;)Ljava/io/InputStream;
    //   10: astore_1
    //   11: new 275	android/graphics/BitmapFactory$Options
    //   14: dup
    //   15: invokespecial 276	android/graphics/BitmapFactory$Options:<init>	()V
    //   18: astore 6
    //   20: aload 6
    //   22: iconst_1
    //   23: putfield 279	android/graphics/BitmapFactory$Options:inJustDecodeBounds	Z
    //   26: aload_1
    //   27: aconst_null
    //   28: aload 6
    //   30: invokestatic 282	android/graphics/BitmapFactory:decodeStream	(Ljava/io/InputStream;Landroid/graphics/Rect;Landroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;
    //   33: pop
    //   34: aload_0
    //   35: aload 6
    //   37: getfield 285	android/graphics/BitmapFactory$Options:outWidth	I
    //   40: putfield 287	com/appwoo/txtws/activity/CropActivity:width	I
    //   43: aload_0
    //   44: aload 6
    //   46: getfield 290	android/graphics/BitmapFactory$Options:outHeight	I
    //   49: putfield 292	com/appwoo/txtws/activity/CropActivity:height	I
    //   52: aload_1
    //   53: ifnull +7 -> 60
    //   56: aload_1
    //   57: invokevirtual 220	java/io/InputStream:close	()V
    //   60: return
    //   61: astore 4
    //   63: aload 4
    //   65: invokevirtual 223	java/io/IOException:printStackTrace	()V
    //   68: aload_1
    //   69: ifnull -9 -> 60
    //   72: aload_1
    //   73: invokevirtual 220	java/io/InputStream:close	()V
    //   76: return
    //   77: astore 5
    //   79: return
    //   80: astore_2
    //   81: aload_1
    //   82: ifnull +7 -> 89
    //   85: aload_1
    //   86: invokevirtual 220	java/io/InputStream:close	()V
    //   89: aload_2
    //   90: athrow
    //   91: astore_3
    //   92: goto -3 -> 89
    //   95: astore 8
    //   97: return
    //
    // Exception table:
    //   from	to	target	type
    //   2	52	61	java/io/IOException
    //   72	76	77	java/io/IOException
    //   2	52	80	finally
    //   63	68	80	finally
    //   85	89	91	java/io/IOException
    //   56	60	95	java/io/IOException
  }

  private String getFilePath(Uri paramUri)
  {
    try
    {
      if (paramUri.getScheme().equals("file"))
        return paramUri.getPath();
      String str = getFilePathByUri(paramUri);
      return str;
    }
    catch (FileNotFoundException localFileNotFoundException)
    {
    }
    return null;
  }

  private String getFilePathByUri(Uri paramUri)
    throws FileNotFoundException
  {
    Cursor localCursor = this.mContentResolver.query(paramUri, null, null, null, null);
    localCursor.moveToFirst();
    return localCursor.getString(1);
  }

  private InputStream getInputStream(Uri paramUri)
    throws IOException
  {
    try
    {
      if (paramUri.getScheme().equals("file"))
        return new FileInputStream(paramUri.getPath());
      InputStream localInputStream = this.mContentResolver.openInputStream(paramUri);
      return localInputStream;
    }
    catch (FileNotFoundException localFileNotFoundException)
    {
    }
    return null;
  }

  private void initActionBar()
  {
    hideBarHome();
    setBarTitle(getResources().getString(2131427338));
    setBarBackOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        CropActivity.this.finish();
      }
    });
  }

  private void initBitmap()
  {
    Matrix localMatrix = new Matrix();
    localMatrix.setRotate(90.0F);
    int i = this.mBitmap.getWidth();
    int j = this.mBitmap.getHeight();
    try
    {
      this.mBitmap = Bitmap.createBitmap(this.mBitmap, 0, 0, i, j, localMatrix, true);
      return;
    }
    catch (OutOfMemoryError localOutOfMemoryError)
    {
      localMatrix.postScale(1.0F / this.sampleSize, 1.0F / this.sampleSize);
      this.mBitmap = Bitmap.createBitmap(this.mBitmap, 0, 0, i, j, localMatrix, true);
    }
  }

  private void initViews()
  {
    this.mImageView = ((CropImageView)findViewById(2131493061));
    this.mImageView.mContext = this;
    this.mBtnSave = ((Button)findViewById(2131493060));
    this.mBtnSave.setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        CropActivity.this.showProgress("");
        CropActivity.this.onSaveClicked();
      }
    });
    this.mBtnSave.setVisibility(0);
  }

  private boolean isRotateImage(String paramString)
  {
    try
    {
      int i = new ExifInterface(paramString).getAttributeInt("Orientation", 1);
      if (i == 6)
        return true;
    }
    catch (IOException localIOException)
    {
      localIOException.printStackTrace();
    }
    return false;
  }

  private void onRotateClicked()
  {
    startFaceDetection(true);
  }

  private void onSaveClicked()
  {
    if (this.mCrop == null);
    while (this.mSaving)
      return;
    this.mSaving = true;
    Rect localRect1 = this.mCrop.getCropRect();
    int i = localRect1.width();
    int j = localRect1.height();
    final Bitmap localBitmap = Bitmap.createBitmap(i, j, Bitmap.Config.RGB_565);
    Canvas localCanvas = new Canvas(localBitmap);
    Rect localRect2 = new Rect(0, 0, i, j);
    localCanvas.drawBitmap(this.mBitmap, localRect1, localRect2, null);
    this.mImageView.clear();
    this.mBitmap.recycle();
    this.mBitmap = null;
    this.mImageView.setImageBitmapResetBase(localBitmap, true);
    this.mImageView.center(true, true);
    this.mImageView.mHighlightViews.clear();
    this.mBtnSave.setVisibility(8);
    final String str;
    File localFile;
    if ((Global.isSDCard()) && (Global.getSDCardSize(this) >= 30))
    {
      this.sdCard = 0;
      str = "app_bg" + System.currentTimeMillis() + ".png";
      if (this.sdCard != 0)
        break label300;
      localFile = new File(Environment.getExternalStorageDirectory(), "tylw");
      if ((localFile != null) && (!localFile.exists()))
        localFile.mkdirs();
    }
    for (this.cropPath01 = (localFile.getAbsolutePath() + File.separator + str); ; this.cropPath01 = (getFilesDir().getParent() + File.separator + getFilesDir().getName() + File.separator + str))
    {
      this.mHandler.post(new Runnable()
      {
        public void run()
        {
          CropActivity.this.saveDrawableToCache(localBitmap, CropActivity.this.cropPath01, str);
        }
      });
      return;
      if (Global.getMemorySize() < 30)
        break;
      this.sdCard = 1;
      break;
      label300: if (this.sdCard != 1)
        break label362;
    }
    label362: alertMessage(getString(2131427437));
  }

  // ERROR //
  private void saveDrawableToCache(Bitmap paramBitmap, String paramString1, String paramString2)
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore 4
    //   3: aload_0
    //   4: getfield 96	com/appwoo/txtws/activity/CropActivity:sdCard	I
    //   7: iconst_1
    //   8: if_icmpne +54 -> 62
    //   11: aload_0
    //   12: aload_3
    //   13: iconst_1
    //   14: invokevirtual 550	com/appwoo/txtws/activity/CropActivity:openFileOutput	(Ljava/lang/String;I)Ljava/io/FileOutputStream;
    //   17: astore 4
    //   19: aload_1
    //   20: getstatic 556	android/graphics/Bitmap$CompressFormat:PNG	Landroid/graphics/Bitmap$CompressFormat;
    //   23: bipush 100
    //   25: aload 4
    //   27: invokevirtual 560	android/graphics/Bitmap:compress	(Landroid/graphics/Bitmap$CompressFormat;ILjava/io/OutputStream;)Z
    //   30: pop
    //   31: iconst_1
    //   32: putstatic 563	com/appwoo/txtws/component/Global:isAppChangeWallpaper	Z
    //   35: invokestatic 568	com/appwoo/txtws/component/FilterSoft:IsCustomVersion	()Z
    //   38: ifeq +8 -> 46
    //   41: aload_0
    //   42: aload_1
    //   43: invokevirtual 571	com/appwoo/txtws/activity/CropActivity:setWallpaper	(Landroid/graphics/Bitmap;)V
    //   46: aload_0
    //   47: aload_2
    //   48: invokespecial 574	com/appwoo/txtws/activity/CropActivity:writeToSP	(Ljava/lang/String;)V
    //   51: aload 4
    //   53: ifnull +8 -> 61
    //   56: aload 4
    //   58: invokevirtual 577	java/io/FileOutputStream:close	()V
    //   61: return
    //   62: new 576	java/io/FileOutputStream
    //   65: dup
    //   66: new 240	java/io/File
    //   69: dup
    //   70: aload_2
    //   71: invokespecial 242	java/io/File:<init>	(Ljava/lang/String;)V
    //   74: invokespecial 580	java/io/FileOutputStream:<init>	(Ljava/io/File;)V
    //   77: astore 9
    //   79: aload 9
    //   81: astore 4
    //   83: goto -64 -> 19
    //   86: astore 7
    //   88: ldc_w 582
    //   91: aload 7
    //   93: invokevirtual 585	java/io/IOException:getMessage	()Ljava/lang/String;
    //   96: invokestatic 591	com/appwoo/txtws/component/Logger:e	(Ljava/lang/String;Ljava/lang/String;)V
    //   99: aload 7
    //   101: invokevirtual 223	java/io/IOException:printStackTrace	()V
    //   104: aload 4
    //   106: ifnull -45 -> 61
    //   109: aload 4
    //   111: invokevirtual 577	java/io/FileOutputStream:close	()V
    //   114: return
    //   115: astore 8
    //   117: aload 8
    //   119: invokevirtual 223	java/io/IOException:printStackTrace	()V
    //   122: return
    //   123: astore 5
    //   125: aload 4
    //   127: ifnull +8 -> 135
    //   130: aload 4
    //   132: invokevirtual 577	java/io/FileOutputStream:close	()V
    //   135: aload 5
    //   137: athrow
    //   138: astore 6
    //   140: aload 6
    //   142: invokevirtual 223	java/io/IOException:printStackTrace	()V
    //   145: goto -10 -> 135
    //   148: astore 11
    //   150: aload 11
    //   152: invokevirtual 223	java/io/IOException:printStackTrace	()V
    //   155: return
    //
    // Exception table:
    //   from	to	target	type
    //   3	19	86	java/io/IOException
    //   19	46	86	java/io/IOException
    //   46	51	86	java/io/IOException
    //   62	79	86	java/io/IOException
    //   109	114	115	java/io/IOException
    //   3	19	123	finally
    //   19	46	123	finally
    //   46	51	123	finally
    //   62	79	123	finally
    //   88	104	123	finally
    //   130	135	138	java/io/IOException
    //   56	61	148	java/io/IOException
  }

  private static void startBackgroundJob(MonitoredActivity paramMonitoredActivity, String paramString1, String paramString2, Runnable paramRunnable, Handler paramHandler)
  {
    new Thread(new BackgroundJob(paramMonitoredActivity, paramRunnable, ProgressDialog.show(paramMonitoredActivity, paramString1, paramString2, true, false), paramHandler)).start();
  }

  private void startFaceDetection(boolean paramBoolean)
  {
    if (isFinishing())
      return;
    if (paramBoolean)
      initBitmap();
    this.mImageView.setImageBitmapResetBase(this.mBitmap, true);
    startBackgroundJob(this, null, getResources().getString(2131427516), new Runnable()
    {
      public void run()
      {
        final CountDownLatch localCountDownLatch = new CountDownLatch(1);
        CropActivity.this.mHandler.post(new Runnable()
        {
          public void run()
          {
            Bitmap localBitmap = CropActivity.this.mBitmap;
            if ((localBitmap != CropActivity.this.mBitmap) && (localBitmap != null))
            {
              CropActivity.this.mImageView.setImageBitmapResetBase(localBitmap, true);
              CropActivity.this.mBitmap.recycle();
              CropActivity.this.mBitmap = localBitmap;
            }
            if (CropActivity.this.mImageView.getScale() == 1.0F)
              CropActivity.this.mImageView.center(true, true);
            localCountDownLatch.countDown();
          }
        });
        try
        {
          localCountDownLatch.await();
          CropActivity.this.mRunFaceDetection.run();
          return;
        }
        catch (InterruptedException localInterruptedException)
        {
          throw new RuntimeException(localInterruptedException);
        }
      }
    }
    , this.mHandler);
  }

  private void writeToSP(String paramString)
  {
    SharedPreferences localSharedPreferences = getSharedPreferences("wallpaper", 0);
    String str = localSharedPreferences.getString("wallpaperValue", null);
    if ((str != null) && (!"".equals(str)))
    {
      File localFile = new File(str);
      if ((localFile != null) && (localFile.exists()))
        localFile.delete();
    }
    SharedPreferences.Editor localEditor = localSharedPreferences.edit();
    localEditor.putString("wallpaperType", this.wallpaperType);
    localEditor.putString("wallpaperValue", paramString);
    localEditor.commit();
    this.mHandler2.sendEmptyMessage(1);
  }

  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(2130903078);
    initActionBar();
    initViews();
    Intent localIntent = getIntent();
    this.wallpaperType = localIntent.getStringExtra("wallpaperType");
    boolean bool2;
    if ("phoneAlbum".equals(this.wallpaperType))
    {
      this.targetUri = ((Uri)localIntent.getParcelableExtra("wallpaperValue"));
      this.mContentResolver = getContentResolver();
      bool2 = isRotateImage(getFilePath(this.targetUri));
      getBitmapSize();
    }
    while (true)
    {
      if (this.mBitmap == null)
        getBitmap();
      if ((this.mBitmap != null) || (this.isDownload))
        break;
      if (this.tipLoadFail)
        Toast.makeText(this, getString(2131428224), 0).show();
      finish();
      return;
      boolean bool1 = "appInner".equals(this.wallpaperType);
      bool2 = false;
      if (bool1)
      {
        this.mDBHelper = new DBHelper(this);
        this.wallpaperValue = localIntent.getStringExtra("wallpaperValue");
        int i = Integer.valueOf(this.wallpaperValue).intValue();
        this.wb = this.mDBHelper.getWallpaperById(i);
        bool2 = false;
      }
    }
    if (this.mBitmap != null)
      startFaceDetection(bool2);
    this.mHandler2 = new Handler()
    {
      public void handleMessage(Message paramAnonymousMessage)
      {
        switch (paramAnonymousMessage.what)
        {
        default:
          return;
        case 1:
        }
        CropActivity.this.closeProgress();
        Toast.makeText(CropActivity.this, CropActivity.this.getString(2131428225), 0).show();
        CropActivity.this.finish();
      }
    };
  }

  protected void onDestroy()
  {
    super.onDestroy();
  }

  protected void onPause()
  {
    super.onPause();
  }

  private static class BackgroundJob extends MonitoredActivity.LifeCycleAdapter
    implements Runnable
  {
    private final MonitoredActivity mActivity;
    private final Runnable mCleanupRunner = new Runnable()
    {
      public void run()
      {
        CropActivity.BackgroundJob.this.mActivity.removeLifeCycleListener(CropActivity.BackgroundJob.this);
        if (CropActivity.BackgroundJob.this.mDialog.getWindow() != null)
          CropActivity.BackgroundJob.this.mDialog.dismiss();
      }
    };
    private final ProgressDialog mDialog;
    private final Handler mHandler;
    private final Runnable mJob;

    public BackgroundJob(MonitoredActivity paramMonitoredActivity, Runnable paramRunnable, ProgressDialog paramProgressDialog, Handler paramHandler)
    {
      this.mActivity = paramMonitoredActivity;
      this.mDialog = paramProgressDialog;
      this.mJob = paramRunnable;
      this.mActivity.addLifeCycleListener(this);
      this.mHandler = paramHandler;
    }

    public void onActivityDestroyed(MonitoredActivity paramMonitoredActivity)
    {
      this.mCleanupRunner.run();
      this.mHandler.removeCallbacks(this.mCleanupRunner);
    }

    public void onActivityStarted(MonitoredActivity paramMonitoredActivity)
    {
      this.mDialog.show();
    }

    public void onActivityStopped(MonitoredActivity paramMonitoredActivity)
    {
      this.mDialog.hide();
    }

    public void run()
    {
      try
      {
        this.mJob.run();
        return;
      }
      finally
      {
        this.mHandler.post(this.mCleanupRunner);
      }
    }
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.activity.CropActivity
 * JD-Core Version:    0.6.2
 */